package cn.cj.erp.common.utils;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;

/**
 * 断言
 *
 * @author jianchen
 */
@Slf4j
public class Assert extends org.springframework.util.Assert {
    /**
     * 正则表达式字符串：弱密码
     */
    public static final String REG_STRONG_PASS = "^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$";

    /**
     * 强密码校验
     */
    public static void strongPass(String str, String message) {
        if (StrUtil.isEmpty(str)) {
            throw new IllegalArgumentException(message);
        }
        if (!str.matches(REG_STRONG_PASS)) {
            throw new IllegalArgumentException(message);
        }
    }

    public static void notEmpty(byte[] array, String message) {
        if (ArrayUtil.isEmpty(array)) {
            throw new IllegalArgumentException(message);
        }
    }

    public static void notEmpty(String str, String message) {
        if (StrUtil.isEmpty(str)) {
            throw new IllegalArgumentException(message);
        }
    }
}
